Predicting motion vectors for fields of forward-predicted interlaced video frames

ABSTRACT

Techniques and tools for encoding and decoding predicted images in interlaced video are described. For example, a video encoder or decoder computes a motion vector predictor for a motion vector for a portion (e.g., a block or macroblock) of an interlaced P-field, including selecting between using a same polarity or opposite polarity motion vector predictor for the portion. The encoder/decoder processes the motion vector based at least in part on the motion vector predictor computed for the motion vector. The processing can comprise computing a motion vector differential between the motion vector and the motion vector predictor during encoding and reconstructing the motion vector from a motion vector differential and the motion vector predictor during decoding. The selecting can be based at least in part on a count of opposite polarity motion vectors for a neighborhood around the portion and/or a count of same polarity motion vectors.

RELATED APPLICATION INFORMATION

This application claims the benefit of U.S. Provisional Patent Application No. 60/501,081, entitled “Video Encoding and Decoding Tools and Techniques,” filed Sep. 7, 2003, which is hereby incorporated by reference.

TECHNICAL FIELD

Techniques and tools for interlaced video coding and decoding are described. For example, a video encoder/decoder calculates motion vector predictors for fields in interlaced video frames.

BACKGROUND

Digital video consumes large amounts of storage and transmission capacity. A typical raw digital video sequence includes 15 or 30 pictures per second. Each picture can include tens or hundreds of thousands of pixels (also called pels). Each pixel represents a tiny element of the picture. In raw form, a computer commonly represents a pixel with 24 bits or more. Thus, the number of bits per second, or bit rate, of a typical raw digital video sequence can be 5 million bits/second or more.

Many computers and computer networks lack the resources to process raw digital video. For this reason, engineers use compression (also called coding or encoding) to reduce the bit rate of digital video. Compression can be lossless, in which quality of the video does not suffer but decreases in bit rate are limited by the complexity of the video. Or, compression can be lossy, in which quality of the video suffers but decreases in bit rate are more dramatic. Decompression reverses compression.

In general, video compression techniques include “intra” compression and “inter” or predictive compression. Intra compression techniques compress individual pictures, typically called I-pictures or key pictures. Inter compression techniques compress pictures with reference to preceding and/or following pictures, and are typically called predicted pictures, P-pictures, or B-pictures.

I. Inter Compression in Windows Media Video, Versions 8 and 9

Microsoft Corporation's Windows Media Video, Version 8 [“WMV8”] includes a video encoder and a video decoder. The WMV8 encoder uses intra and inter compression, and the WMV8 decoder uses intra and inter decompression. Early versions of Windows Media Video, Version 9 [“WMV9”] use a similar architecture for many operations.

Inter compression in the WMV8 encoder uses block-based motion compensated prediction coding followed by transform coding of the residual error. FIGS. 1 and 2 illustrate the block-based inter compression for a predicted frame in the WMV8 encoder. In particular, FIG. 1 illustrates motion estimation for a predicted frame 110 and FIG. 2 illustrates compression of a prediction residual for a motion-compensated block of a predicted frame.

For example, in FIG. 1, the WMV8 encoder computes a motion vector for a macroblock 115 in the predicted frame 110. To compute the motion vector, the encoder searches in a search area 135 of a reference frame 130. Within the search area 135, the encoder compares the macroblock 115 from the predicted frame 110 to various candidate macroblocks in order to find a candidate macroblock that is a good match. The encoder outputs information specifying the motion vector (entropy coded) for the matching macroblock.

Since a motion vector value is often correlated with the values of spatially surrounding motion vectors, compression of the data used to transmit the motion vector information can be achieved by selecting a motion vector predictor from neighboring macroblocks and predicting the motion vector for the current macroblock using the predictor. The encoder can encode the differential between the motion vector and the predictor. After reconstructing the motion vector by adding the differential to the predictor, a decoder uses the motion vector to compute a prediction macroblock for the macroblock 115 using information from the reference frame 130, which is a previously reconstructed frame available at the encoder and the decoder. The prediction is rarely perfect, so the encoder usually encodes blocks of pixel differences (also called the error or residual blocks) between the prediction macroblock and the macroblock 115 itself.

FIG. 2 illustrates an example of computation and encoding of an error block 235 in the WMV8 encoder. The error block 235 is the difference between the predicted block 215 and the original current block 225. The encoder applies a DCT 240 to the error block 235, resulting in an 8×8 block 245 of coefficients. The encoder then quantizes 250 the DCT coefficients, resulting in an 8×8 block of quantized DCT coefficients 255. The encoder scans 260 the 8×8 block 255 into a one-dimensional array 265 such that coefficients are generally ordered from lowest frequency to highest frequency. The encoder entropy encodes the scanned coefficients using a variation of run length coding 270. The encoder selects an entropy code from one or more run/level/last tables 275 and outputs the entropy code.

FIG. 3 shows an example of a corresponding decoding process 300 for an inter-coded block. In summary of FIG. 3, a decoder decodes (310, 320) entropy-coded information representing a prediction residual using variable length decoding 310 with one or more run/level/last tables 315 and run length decoding 320. The decoder inverse scans 330 a one-dimensional array 325 storing the entropy-decoded information into a two-dimensional block 335. The decoder inverse quantizes and inverse discrete cosine transforms (together, 340) the data, resulting in a reconstructed error block 345. In a separate motion compensation path, the decoder computes a predicted block 365 using motion vector information 355 for displacement from a reference frame. The decoder combines 370 the predicted block 365 with the reconstructed error block 345 to form the reconstructed block 375.

The amount of change between the original and reconstructed frames is the distortion and the number of bits required to code the frame indicates the rate for the frame. The amount of distortion is roughly inversely proportional to the rate.

II. Interlaced Video and Progressive Video

A typical interlaced video frame consists of two fields scanned starting at different times. For example, referring to FIG. 4, an interlaced video frame 400 includes top field 410 and bottom field 420. Typically, the even-numbered lines (top field) are scanned starting at one time (e.g., time t) and the odd-numbered lines (bottom field) are scanned starting at a different (typically later) time (e.g., time t+1). This timing can create jagged tooth-like features in regions of an interlaced video frame where motion is present because the two fields are scanned starting at different times. For this reason, interlaced video frames can be rearranged according to a field structure, with the odd lines grouped together in one field, and the even lines grouped together in another field. This arrangement, known as field coding, is useful in high-motion pictures for reduction of such jagged edge artifacts. On the other hand, in stationary regions, image detail in the interlaced video frame may be more efficiently preserved without such a rearrangement. Accordingly, frame coding is often used in stationary or low-motion interlaced video frame, in which the original alternating field line arrangement is preserved.

A typical progressive video frame consists of one frame of content with non-alternating lines. In contrast to interlaced video, progressive video does not divide video frames into separate fields, and an entire frame is scanned left to right, top to bottom starting at a single time.

Ill. Interlace P-frame Coding and Decoding in Early Versions of WMV9

Early versions of Windows Media Video, Version 9 [“WMV9”] use interlace P-frame coding and decoding. In these early versions of WMV9, interlaced P-frames can contain macroblocks encoded in field mode or in frame mode, or skipped macroblocks, with a decision generally made on a macroblock-by-macroblock basis. Two motion vectors are associated with each field-coded macroblock, and one motion vector is associated with each frame-coded macroblock. An encoder jointly encodes motion information for the blocks in the macroblock, including horizontal and vertical motion vector differential components, potentially along with other signaling information.

In the encoder, a motion vector is encoded by computing a differential between the motion vector and a motion vector predictor, which is computed based on neighboring motion vectors. And, in the decoder, the motion vector is reconstructed by adding the motion vector differential to the motion vector predictor, which is again computed (this time in the decoder) based on neighboring motion vectors.

FIGS. 5, 6, and 7 show examples of candidate predictors for motion vector prediction for frame-coded macroblocks and field-coded macroblocks, respectively, in interlaced P-frames in early versions of WMV9. FIG. 5 shows candidate predictors A, B and C for a current frame-coded macroblock in an interior position in an interlaced P-frame (not the first or last macroblock in a macroblock row, not in the top row). Predictors can be obtained from different candidate directions other than those labeled A, B, and C (e.g., in special cases such as when the current macroblock is the first macroblock or last macroblock in a row, or in the top row, since certain predictors are unavailable for such cases). For a current frame-coded macroblock, predictor candidates are calculated differently depending on whether the neighboring macroblocks are field-coded or frame-coded. For a neighboring frame-coded macroblock, the motion vector is simply taken as the predictor candidate. For a neighboring field-coded macroblock, the candidate motion vector is determined by averaging the top and bottom field motion vectors.

FIGS. 6 and 7 show candidate predictors A, B and C for a current field in a field-coded macroblock that is not the first or last macroblock in a macroblock row, and not in the top row. In FIG. 6, the current field is a bottom field, and the bottom field motion vectors in the neighboring macroblocks are used as candidate predictors. In FIG. 7, the current field is a top field, and the top field motion vectors are used as candidate predictors. Thus, for each field in a current field-coded macroblock, the number of motion vector predictor candidates for each field is at most three, with each candidate coming from the same field type (e.g., top or bottom) as the current field.

A predictor for the current macroblock or field of the current macroblock is selected based on the candidate predictors, and a motion vector differential is calculated based on the predictor. The motion vector can be reconstructed by adding the motion vector differential to the selected motion vector predictor at either the encoder or the decoder side. Typically, luminance motion vectors are reconstructed from the encoded motion information, and chrominance motion vectors are derived from the reconstructed luminance motion vectors.

IV. Standards for Video Compression and Decompression

Aside from WMV8 and early versions of WMV9, several international standards relate to video compression and decompression. These standards include the Motion Picture Experts Group [“MPEG”] 1, 2, and 4 standards and the H.261, H.262, H.263, and H.264 standards from the International Telecommunication Union [“ITU”]. One of the primary methods used to achieve data compression of digital video sequences in the international standards is to reduce the temporal redundancy between pictures. These popular compression schemes (MPEG-1, MPEG-2, MPEG4, H.261, H.263, etc) use motion estimation and compensation. For example, a current frame is divided into uniform square regions (e.g., blocks and/or macroblocks). A matching region for each current region is specified by sending motion vector information for the region. The motion vector indicates the location of the region in a previously coded (and reconstructed) frame that is to be used as a predictor for the current region. A pixel-by-pixel difference, called the error signal, between the current region and the region in the reference frame is derived. This error signal usually has lower entropy than the original signal. Therefore, the information can be encoded at a lower rate. As in WMV8 and early versions of WMV9, since a motion vector value is often correlated with spatially surrounding motion vectors, compression of the data used to represent the motion vector information can be achieved by coding the differential between the current motion vector and a predictor based upon previously coded, neighboring motion vectors.

In addition, some international standards describe motion estimation and compensation in interlaced video frames. The H.262 standard allows an interlaced video frame to be encoded as a single frame or as two fields, where the frame encoding or field encoding can be adaptively selected on a frame-by-frame basis. The H.262 standard describes field-based prediction, which is a prediction mode using only one field of a reference frame. The H.262 standard also describes dual-prime prediction, which is a prediction mode in which two forward field-based predictions are averaged for a 16×16 block in an interlaced P-picture. Section 7.6 of the H.262 standard describes “field prediction,” including selecting between two reference fields to use for motion compensation for a macroblock of a current field of an interlaced video frame. Section 7.6.3 describes motion vector prediction and reconstruction, in which a reconstructed motion vector for a given macroblock becomes the motion vector predictor for a subsequently encoded/decoded macroblock. Such motion vector prediction fails to adequately predict motion vectors for macroblocks of fields of interlaced video frames in many cases.

Given the critical importance of video compression and decompression to digital video, it is not surprising that video compression and decompression are richly developed fields. Whatever the benefits of previous video compression and decompression techniques, however, they do not have the advantages of the following techniques and tools.

SUMMARY

In summary, the detailed description is directed to various techniques and tools for encoding and decoding predicted video images in interlaced video. Described techniques include those for computing motion vector predictors for block or macroblocks of fields of interlaced video frames. These techniques improve the accuracy of motion vector prediction in many cases, thereby reducing the bitrate associated with encoding motion vector information for fields of interlaced video frames. The various techniques and tools can be used in combination or independently.

In a first aspect, an encoder/decoder computes a motion vector predictor for a motion vector for a portion (e.g., a block or macroblock) of an interlaced P-field, including selecting between using a same polarity motion vector predictor or using an opposite polarity motion vector predictor for the portion. The encoder/decoder processes the motion vector based at least in part on the motion vector predictor computed for the motion vector. The processing can comprise computing a motion vector differential between the motion vector and the motion vector predictor during encoding and reconstructing the motion vector from a motion vector differential and the motion vector predictor during decoding. The selecting can be based at least in part on a count of opposite polarity motion vectors for a neighborhood around the portion and/or a count of same polarity motion vectors for the neighborhood. The selecting also can be based at least in part on a single bit signal in a bit stream. The selecting can comprise determining a dominant predictor based at least in part on a count of opposite polarity motion vectors for a neighborhood around the portion and/or a count of same polarity motion vectors for the neighborhood, and selecting the same polarity motion vector predictor or the opposite polarity motion vector predictor based upon the dominant predictor and a single bit signal in a bit stream.

The selecting also can comprise selecting the same polarity motion vector predictor if the motion vector for the portion refers to a same polarity field, or selecting the opposite polarity motion vector predictor if the motion vector for the portion refers to an opposite polarity field.

The same polarity motion vector predictor can be computed as a median of plural same polarity motion vector predictor candidates for a neighborhood around the portion, and the opposite polarity motion vector predictor can be computed as a median of plural opposite polarity motion vector predictor candidates for a neighborhood around the portion. Same polarity motion vector predictor candidates can be derived by scaling an opposite polarity motion vector predictor candidate, and opposite polarity motion vector predictor candidates can be derived by scaling a same polarity motion vector predictor candidate.

In another aspect, an encoder/decoder computes a motion vector predictor for a motion vector for a portion of an interlaced P-field based at least in part on plural neighboring motion vectors, wherein the plural neighboring motion vectors include one or more opposite polarity motion vectors and one or more same polarity motion vectors. The encoder/decoder processes the motion vector based at least in part on the motion vector predictor computed for the motion vector. A same polarity motion vector predictor can be computed as a median of plural same polarity motion vector predictor candidates, wherein at least one of the plural candidates is derived based at least in part on scaling a value from one of the one or more opposite polarity motion vectors, and an opposite polarity motion vector predictor can be computed as a median of plural opposite polarity motion vector predictor candidates, wherein at least one of the plural candidates is derived based at least in part on scaling a value from one of the one or more same polarity motion vectors.

In another aspect, an encoder/decoder processes an interlaced predicted video frame by determining a first set of motion vector predictor candidates for a macroblock in a current field in the video frame, the first set of motion vector predictor candidates referencing a first reference field having a same polarity relative to the current field. A first motion vector predictor is computed for the macroblock based at least in part on one or more of the first set of motion vector predictor candidates. A second set of motion vector predictor candidates is determined for the macroblock, the second set of motion vector predictor candidates referencing a second reference field having an opposite polarity relative to the current field. A second motion vector predictor for the macroblock is computed based at least in part on one or more of the second set of motion vector predictor candidates.

The first and second motion vector predictors are used in the processing, such as by selecting one of the first and second motion vector predictors and calculating a motion vector differential for the macroblock based on the selected motion vector predictor, and/or by selecting one of the first and second motion vector predictors and combining the selected predictor with the motion vector differential to reconstruct a motion vector for the macroblock. The motion vector differential can be entropy coded.

In another aspect, a first polarity motion vector predictor candidate is computed by scaling an actual motion vector value having a second polarity different than the first polarity. The first polarity motion vector predictor candidate is used when computing a motion vector predictor for a motion vector for a portion of an interlaced P-field. A motion vector differential can be computed between the motion vector and the motion vector predictor during encoding. The motion vector can be reconstructed from a motion vector differential and the motion vector predictor during decoding. The first polarity motion vector predictor candidate can have the opposite field polarity as the portion, wherein the actual motion vector value has the same field polarity as the portion, and wherein the scaling is adapted to scale from the same polarity to the opposite polarity. Or, the first polarity motion vector predictor candidate can have the same field polarity as the portion, wherein the actual motion vector value has the opposite field polarity as the portion, and wherein the scaling is adapted to scale from the opposite polarity to the same polarity. Scaling can be based at least in part on a reference frame distance.

In another aspect, an encoder/decoder determines a first motion vector predictor candidate for a macroblock in a current field in the video frame, the first motion vector predictor candidate having a first polarity. The encoder/decoder determines a second motion vector predictor candidate for the macroblock, wherein the second motion vector predictor candidate is derived from the first motion vector predictor candidate using a scaling operation. The second motion vector predictor candidate has a polarity different than the first polarity.

In another aspect, an encoder/decoder determines a first motion vector predictor candidate for a macroblock in a current field in the video frame, the first motion vector predictor candidate referencing a field having a first polarity and a reference distance. The encoder/decoder determines a second motion vector predictor candidate for the macroblock, wherein the second motion vector predictor candidate is derived from the first motion vector predictor candidate using a scaling operation that varies based at least in part on the reference distance. The second motion vector predictor candidate can have a polarity different than the first polarity.

In another aspect, a decoder decodes a first element at a field level in a bitstream, and a second element and third element at a macroblock level in the bitstream. The first element comprises number-of-reference-field information for a current field in the video frame, which indicates two reference fields for the current field. The second element comprises macroblock mode information for a current macroblock in the current field. The third element comprises motion vector data for the current macroblock, wherein the motion vector data includes differential motion vector data. The decoder processes the motion vector data for the macroblock. The processing comprises determining first and second motion vector predictors for the current macroblock, and reconstructing a motion vector for the current macroblock based at least in part on the first and second motion vector predictors and based at least in part on the differential motion vector data. The first motion vector predictor is an odd field predictor and the second motion vector predictor is an even field predictor.

In another aspect, a decoder decodes motion vector data that collectively signal a horizontal differential motion vector component, a vertical differential motion vector component, and flag indicating whether to use a dominant or non-dominant motion vector predictor. The decoder reconstructs a motion vector based at least in part on the decoded motion vector data. The reconstructing can comprise selecting between using the dominant motion vector predictor or the non-dominant motion vector predictor based on the flag, combining the horizontal differential motion vector component with a horizontal component of the selected predictor, and combining the vertical differential motion vector component with a horizontal component of the selected predictor.

Additional features and advantages will be made apparent from the following detailed description of different embodiments that proceeds with reference to the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram showing motion estimation in a video encoder according to the prior art.

FIG. 2 is a diagram showing block-based compression for an 8×8 block of prediction residuals in a video encoder according to the prior art.

FIG. 3 is a diagram showing block-based decompression for an 8×8 block of prediction residuals in a video encoder according to the prior art.

FIG. 4 is a diagram showing an interlaced video frame according to the prior art.

FIG. 5 is a diagram showing candidate motion vector predictors for a current frame-coded macroblock in early versions of WMV9.

FIGS. 6 and 7 are diagrams showing candidate motion vector predictors for a current field-coded macroblock in early versions of WMV9.

FIG. 8 is a block diagram of a suitable computing environment in conjunction with which several described embodiments may be implemented.

FIG. 9 is a block diagram of a generalized video encoder system in conjunction with which several described embodiments may be implemented.

FIG. 10 is a block diagram of a generalized video decoder system in conjunction with which several described embodiments may be implemented.

FIG. 11 is a diagram of a macroblock format used in several described embodiments.

FIG. 12A is a diagram of part of an interlaced video frame, showing alternating lines of a top field and a bottom field. FIG. 12B is a diagram of the interlaced video frame organized for encoding/decoding as a frame, and FIG. 12C is a diagram of the interlaced video frame organized for encoding/decoding as fields.

FIGS. 13 and 14 are code listings showing pseudo-code for performing median-of-3 and median-of-4 calculations, respectively.

FIGS. 15 and 16 are diagrams showing interlaced P-fields each having two reference fields.

FIG. 17 is a diagram showing relationships between vertical components of motion vectors and a corresponding spatial location for different combinations of current and reference field polarities.

FIG. 18 is a flow chart showing a technique for selecting a motion vector predictor for an interlaced P-field having two possible reference fields.

FIG. 19 is a diagram showing two sets of three candidate motion vector predictors for a current macroblock.

FIGS. 20A-20F are code listings showing pseudo-code for calculating motion vector predictors in two-reference interlaced P-fields.

FIGS. 21A-21B are code listings showing pseudo-code for scaling a predictor from one field to derive a predictor from another field.

FIGS. 22 and 23 are tables showing scaling operation values associated with different reference frame distances.

FIG. 24 is a diagram showing a frame-layer bitstream syntax for interlaced P-fields in a combined implementation.

FIG. 25 is a diagram showing a field-layer bitstream syntax for interlaced P-fields in a combined implementation.

FIG. 26 is a diagram showing a macroblock-layer bitstream syntax for interlaced P-fields in a combined implementation.

FIGS. 27A and 27B are code listings showing pseudo-code illustrating decoding of a motion vector differential for a one-reference interlaced P-field.

FIGS. 28A and 28B are code listings showing pseudo-code illustrating decoding of a motion vector differential and dominant/non-dominant predictor information for a two-reference interlaced P-field.

FIGS. 29A and 29B are diagrams showing locations of macroblocks for candidate motion vector predictors for a 1MV macroblock in an interlaced P-field.

FIGS. 30A and 30B are diagrams showing locations of blocks for candidate motion vector predictors for a 1MV macroblock in a mixed 1MV/4MV interlaced P-field.

FIGS. 31A, 31B, 32A, 32B, 33, and 34 are diagrams showing the locations of blocks for candidate motion vector predictors for a block at various positions in a 4MV macroblock in a mixed 1MV/4MV interlaced P-field.

FIGS. 35A-35F are code listings showing pseudo-code for calculating motion vector predictors in two-reference interlaced P-fields in a combined implementation.

FIG. 36 is a code listing showing pseudo-code for determining a reference field in two-reference interlaced P-fields.

DETAILED DESCRIPTION

The present application relates to techniques and tools for efficient compression and decompression of interlaced video. In various described embodiments, for example, a video encoder and decoder incorporate techniques for predicting motion vectors in encoding and decoding predicted fields in interlaced video frames, as well as signaling techniques for use with a bit stream format or syntax comprising different layers or levels (e.g., sequence level, picture/image level, field level, macroblock level, and/or block level). The techniques and tools can be used, for example, in digital video broadcasting systems (e.g., cable, satellite, DSL, etc.).

In particular, described techniques and tools improve the quality of motion vector predictors for blocks and/or macroblocks of forward-predicted fields of interlaced video frames, which in turn allows motion vectors to be more efficiently encoded. For example, techniques are described for generating predictor motion vectors for the blocks and/or macroblocks of a current field using neighborhood motion vectors for surrounding blocks and/or macroblocks, where the neighborhood motion vectors collectively refer to one or both of two fields as references. Innovations implemented in the described techniques and tools include, but are not limited to the following:

-   -   1) Generating two motion vector predictors for a block or         macroblock in an interlaced P-field: one motion vector predictor         for an “even” reference field and one motion vector predictor         for an “odd” reference field. The encoder/decoder considers up         to six motion vector predictor candidates (three for the even         motion vector predictor and three for the odd motion vector         predictor) for a current block or macroblock. Use of up to six         motion vector predictor candidates allows better motion vector         prediction than prior methods.     -   2) Using a motion vector predictor from the reference field that         is referenced by the current motion vector: If the current         motion vector references a region in the corresponding field of         the reference frame (meaning that the current field and         reference field are of the same polarity), the motion vector         predictor from that reference field is used. Similarly, if the         opposite polarity field is used as a reference, the motion         vector predictor from that reference field is used. This allows         better motion vector prediction than prior methods.     -   3) Using a scaling operation to generate motion vector predictor         candidates for the opposite polarity of an existing motion         vector candidate. The encoder/decoder takes a motion vector from         a candidate block/macroblock location, where the motion vector         references either an odd field or an even field. The         encoder/decoder then scales the motion vector to derive a motion         vector predictor candidate of the other polarity. For example,         if the actual motion vector for an adjacent macroblock         references the odd field, that value is used as an odd motion         vector predictor candidate from the adjacent macroblock, and a         scaled motion vector value (derived from the actual value) is         used as an even motion vector predictor candidate from the         adjacent macroblock. Though motion vector predictor candidates         are obtained from only three block/macroblock locations (with         three motion vector values), the encoder/decoder's derivation of         different polarity motion vector predictor candidates gives a         population of six candidates to choose from.     -   4) Using a scaling operation that is dependent on the reference         frame distances when deriving motion vector predictor         candidates. The encoder/decoder uses the relative temporal         distances between the current field and the two reference fields         to perform the scaling operation that derives the predictor         candidate for the missing polarity field from the existing         motion vector candidate from the other field. An encoder/decoder         that takes into account the relative temporal distances to         perform scaling can produce more accurate prediction than an         encoder/decoder that assumes a constant reference distance.

Various alternatives to the implementations described herein are possible. For example, techniques described with reference to flowchart diagrams can be altered by changing the ordering of stages shown in the flowcharts, by repeating or omitting certain stages, etc. As another example, although some implementations are described with reference to specific macroblock and/or block formats, other formats also can be used. Further, techniques and tools described with reference to interlaced P-field type prediction may also be applicable to other types of prediction.

The various techniques and tools can be used in combination or independently. Different embodiments implement one or more of the described techniques and tools. The techniques and tools described herein can be used in a video encoder or decoder, or in some other system not specifically limited to video encoding or decoding.

I. Computing Environment

FIG. 8 illustrates a generalized example of a suitable computing environment 800 in which several of the described embodiments may be implemented. The computing environment 800 is not intended to suggest any limitation as to scope of use or functionality, as the techniques and tools may be implemented in diverse general-purpose or special-purpose computing environments.

With reference to FIG. 8, the computing environment 800 includes at least one processing unit 810 and memory 820. In FIG. 8, this most basic configuration 830 is included within a dashed line. The processing unit 810 executes computer-executable instructions and may be a real or a virtual processor. In a multi-processing system, multiple processing units execute computer-executable instructions to increase processing power. The memory 820 may be volatile memory (e.g., registers, cache, RAM), non-volatile memory (e.g., ROM, EEPROM, flash memory, etc.), or some combination of the two. The memory 820 stores software 880 implementing a video encoder or decoder with two-reference field motion vector prediction for interlaced P-fields.

A computing environment may have additional features. For example, the computing environment 800 includes storage 840, one or more input devices 850, one or more output devices 860, and one or more communication connections 870. An interconnection mechanism (not shown) such as a bus, controller, or network interconnects the components of the computing environment 800. Typically, operating system software (not shown) provides an operating environment for other software executing in the computing environment 800, and coordinates activities of the components of the computing environment 800.

The storage 840 may be removable or non-removable, and includes magnetic disks, magnetic tapes or cassettes, CD-ROMs, DVDs, or any other medium which can be used to store information and which can be accessed within the computing environment 800. The storage 840 stores instructions for the software 880 implementing the video encoder or decoder.

The input device(s) 850 may be a touch input device such as a keyboard, mouse, pen, or trackball, a voice input device, a scanning device, or another device that provides input to the computing environment 800. For audio or video encoding, the input device(s) 850 may be a sound card, video card, TV tuner card, or similar device that accepts audio or video input in analog or digital form, or a CD-ROM or CD—RW that reads audio or video samples into the computing environment 800. The output device(s) 860 may be a display, printer, speaker, CD-writer, or another device that provides output from the computing environment 800.

The communication connection(s) 870 enable communication over a communication medium to another computing entity. The communication medium conveys information such as computer-executable instructions, audio or video input or output, or other data in a modulated data signal. A modulated data signal is a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media include wired or wireless techniques implemented with an electrical, optical, RF, infrared, acoustic, or other carrier.

The techniques and tools can be described in the general context of computer-readable media. Computer-readable media are any available media that can be accessed within a computing environment. By way of example, and not limitation, with the computing environment 800, computer-readable media include memory 820, storage 840, communication media, and combinations of any of the above.

The techniques and tools can be described in the general context of computer-executable instructions, such as those included in program modules, being executed in a computing environment on a target real or virtual processor. Generally, program modules include routines, programs, libraries, objects, classes, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The functionality of the program modules may be combined or split between program modules as desired in various embodiments. Computer-executable instructions for program modules may be executed within a local or distributed computing environment.

For the sake of presentation, the detailed description uses terms like “estimate,” “compensate,” “predict,” and “apply” to describe computer operations in a computing environment. These terms are high-level abstractions for operations performed by a computer, and should not be confused with acts performed by a human being. The actual computer operations corresponding to these terms vary depending on implementation.

II. Generalized Video Encoder and Decoder

FIG. 9 is a block diagram of a generalized video encoder 900 in conjunction with which described embodiments may be implemented. FIG. 10 is a block diagram of a generalized video decoder 1000 in conjunction with which described embodiments may be implemented.

The relationships shown between modules within the encoder 900 and decoder 1000 indicate general flows of information in the encoder and decoder; other relationships are not shown for the sake of simplicity. In particular, FIGS. 9 and 10 usually do not show side information indicating the encoder settings, modes, tables, etc. used for a video sequence, picture, macroblock, block, etc. Such side information is sent in the output bitstream, typically after entropy encoding of the side information. The format of the output bitstream can be a Windows Media Video version 9 format or other format.

The encoder 900 and decoder 1000 process video pictures, which may be video frames, video fields or combinations of frames and fields. The bitstream syntax and semantics at the picture and macroblock levels may depend on whether frames or fields are used. There may be changes to macroblock organization and overall timing as well. The encoder 900 and decoder 1000 are block-based and use a 4:2:0 macroblock format for frames, with each macroblock including four 8×8 luminance blocks (at times treated as one 16×16 macroblock) and two 8×8 chrominance blocks. For fields, the same or a different macroblock organization and format may be used. The 8×8 blocks may be further sub-divided at different stages, e.g., at the frequency transform and entropy encoding stages. Example video frame organizations are described in more detail below. Alternatively, the encoder 900 and decoder 1000 are object-based, use a different macroblock or block format, or perform operations on sets of pixels of different size or configuration than 8×8 blocks and 16×16 macroblocks.

Depending on implementation and the type of compression desired, modules of the encoder or decoder can be added, omitted, split into multiple modules, combined with other modules, and/or replaced with like modules. In alternative embodiments, encoders or decoders with different modules and/or other configurations of modules perform one or more of the described techniques.

A. Video Frame Organizations

In some implementations, the encoder 900 and decoder 1000 process video frames organized as follows. A frame contains lines of spatial information of a video signal. For progressive video, these lines contain samples starting from one time instant and continuing through successive lines to the bottom of the frame. A progressive video frame is divided into macroblocks such as the macroblock 1100 shown in FIG. 11. The macroblock 1100 includes four 8×8 luminance blocks (Y1 through Y4) and two 8×8 chrominance blocks that are co-located with the four luminance blocks but half resolution horizontally and vertically, following the conventional 4:2:0 macroblock format. The 8×8 blocks may be further sub-divided at different stages, e.g., at the frequency transform and entropy encoding stages. A progressive I-frame is an intra-coded progressive video frame. A progressive P-frame is a progressive video frame coded using forward prediction, and a progressive B-frame is a progressive video frame coded using bi-directional prediction. Progressive P and B-frames may include intra-coded macroblocks as well as different types of predicted macroblocks.

For interlaced video, a frame consists of two fields, a top field and a bottom field. One of these fields commences one field period later than the other. FIG. 12 a shows part of an interlaced video frame 1200, including the alternating lines of the top field and bottom field at the top left part of the interlaced video frame 1200.

FIG. 12 b shows the interlaced video frame 1200 of FIG. 12a organized for encoding/decoding as a frame 1230. The interlaced video frame 1200 has been partitioned into macroblocks such as the macroblocks 1231 and 1232, which use 4:2:0 format as shown in FIG. 11. In the luminance plane, each macroblock 1231, 1232 includes 8 lines from the top field alternating with 8 lines from the bottom field for 16 lines total, and each line is 16 pixels long. (The actual organization and placement of luminance blocks and chrominance blocks within the macroblocks 1231, 1232 are not shown, and in fact may vary for different encoding decisions.) Within a given macroblock, the top-field information and bottom-field information may be coded jointly or separately at any of various phases. An interlaced I-frame is two intra-coded fields of an interlaced video frame, where a macroblock includes information for the two fields. An interlaced P-frame is two fields of an interlaced video frame coded using forward prediction, and an interlaced B-frame is two fields of an interlaced video frame coded using bidirectional prediction, where a macroblock includes information for the two fields. Interlaced P and B-frames may include intra-coded macroblocks as well as different types of predicted macroblocks.

FIG. 12 c shows the interlaced video frame 1200 of FIG. 12 a organized for encoding/decoding as fields 1260. Each of the two fields of the interlaced video frame 1200 is partitioned into macroblocks. The top field is partitioned into macroblocks such as the macroblock 1261, and the bottom field is partitioned into macroblocks such as the macroblock 1262. (Again, the macroblocks use 4:2:0 format as shown in FIG. 11, and the organization and placement of luminance blocks and chrominance blocks within the macroblocks are not shown.) In the luminance plane, the macroblock 1261 includes 16 lines from the top field and the macroblock 1262 includes 16 lines from the bottom field, and each line is 16 pixels long. An interlaced I-field is a single, separately represented field of an interlaced video frame. An interlaced P-field is single, separately represented field of an interlaced video frame coded using forward prediction, and an interlaced B-field is a single, separately represented field of an interlaced video frame coded using bidirectional prediction. Interlaced P and B-fields may include intra-coded macroblocks as well as different types of predicted macroblocks.

The term picture generally refers to source, coded or reconstructed image data. For progressive video, a picture is a progressive video frame. For interlaced video, a picture may refer to an interlaced video frame, the top field of the frame, or the bottom field of the frame, depending on the context.

B. Video Encoder

FIG. 9 is a block diagram of a generalized video encoder system 900. The encoder system 900 receives a sequence of video pictures including a current picture 905, and produces compressed video information 995 as output. Particular embodiments of video encoders typically use a variation or supplemented version of the generalized encoder 900.

The encoder system 900 compresses predicted pictures and key pictures. For the sake of presentation, FIG. 9 shows a path for key pictures through the encoder system 900 and a path for predicted pictures. Many of the components of the encoder system 900 are used for compressing both key pictures and predicted pictures. The exact operations performed by those components can vary depending on the type of information being compressed.

A predicted picture (also called p-picture, b-picture for bidirectional prediction, or inter-coded picture) is represented in terms of prediction (or difference) from one or more other pictures (which are typically referred to as reference pictures or anchors). A prediction residual is the difference between what was predicted and the original picture. In contrast, a key picture (also called I-picture, intra-coded picture) is compressed without reference to other pictures.

If the current picture 905 is a forward-predicted picture, a motion estimator 910 estimates motion of macroblocks or other sets of pixels of the current picture 905 with respect to a reference picture or pictures, which is the reconstructed previous picture(s) 925 buffered in the picture store(s) 920, 922. If the current picture 905 is a bi-directionally-predicted picture (a B-picture), a motion estimator 910 estimates motion in the current picture 905 with respect to two or more reconstructed reference pictures. Typically, a motion estimator estimates motion in a B-picture with respect to at least one temporally previous reference picture and at least one temporally future reference picture. Accordingly, the encoder system 900 can use the separate stores 920 and 922 for backward and forward reference pictures. For more information on bi-directionally predicted pictures, see U.S. patent application Ser. No. 10/622,378, entitled, “Advanced Bi-Directional Predictive Coding of Video Frames,” filed Jul. 18, 2003.

The motion estimator 910 can estimate motion by pixel, ½ pixel, ¼ pixel, or other increments, and can switch the resolution of the motion estimation on a picture-by-picture basis or other basis. The resolution of the motion estimation can be the same or different horizontally and vertically. The motion estimator 910 outputs as side information motion information 915 such as differential motion vector information. The encoder 900 encodes the motion information 915 by, for example, computing one or more predictors for motion vectors, computing differentials between the motion vectors and predictors, and entropy coding the differentials. To reconstruct a motion vector, a motion compensator 930 combines a predictor with differential motion vector information. Various techniques for computing motion vector predictors, computing differential motion vectors, and reconstructing motion vectors for interlaced P-fields are described below.

The motion compensator 930 applies the reconstructed motion vector to the reconstructed picture(s) 925 to form a motion-compensated current picture 935. The prediction is rarely perfect, however, and the difference between the motion-compensated current picture 935 and the original current picture 905 is the prediction residual 945. Alternatively, a motion estimator and motion compensator apply another type of motion estimation/compensation.

A frequency transformer 960 converts the spatial domain video information into frequency domain (i.e., spectral) data. For block-based video pictures, the frequency transformer 960 applies a discrete cosine transform [“DCT”], variant of DCT, or other block transform to blocks of the pixel data or prediction residual data, producing blocks of frequency transform coefficients. Alternatively, the frequency transformer 960 applies another conventional frequency transform such as a Fourier transform or uses wavelet or sub-band analysis. The frequency transformer 960 may apply an 8×8, 8×4, 4×8, 4×4 or other size frequency transform.

A quantizer 970 then quantizes the blocks of spectral data coefficients. The quantizer applies uniform, scalar quantization to the spectral data with a step-size that varies on a picture-by-picture basis or other basis. Alternatively, the quantizer applies another type of quantization to the spectral data coefficients, for example, a non-uniform, vector, or non-adaptive quantization, or directly quantizes spatial domain data in an encoder system that does not use frequency transformations. In addition to adaptive quantization, the encoder 900 can use frame dropping, adaptive filtering, or other techniques for rate control.

If a given macroblock in a predicted picture has no information of certain types (e.g., no motion information for the macroblock and no residual information), the encoder 900 may encode the macroblock as a skipped macroblock. If so, the encoder signals the skipped macroblock in the output bitstream of compressed video information 995.

When a reconstructed current picture is needed for subsequent motion estimation/compensation, an inverse quantizer 976 performs inverse quantization on the quantized spectral data coefficients. An inverse frequency transformer 966 then performs the inverse of the operations of the frequency transformer 960, producing a reconstructed prediction residual (for a predicted picture) or a reconstructed key picture. If the current picture 905 was a key picture, the reconstructed key picture is taken as the reconstructed current picture (not shown). If the current picture 905 was a predicted picture, the reconstructed prediction residual is added to the motion-compensated current picture 935 to form the reconstructed current picture. One of the he picture store 920, 922 buffers the reconstructed current picture for use in predicting the next picture. In some embodiments, the encoder applies a de-blocking filter to the reconstructed picture to adaptively smooth discontinuities in the picture.

The entropy coder 980 compresses the output of the quantizer 970 as well as certain side information (e.g., for motion information 915, quantization step size). Typical entropy coding techniques include arithmetic coding, differential coding, Huffman coding, run length coding, LZ coding, dictionary coding, and combinations of the above. The entropy coder 980 typically uses different coding techniques for different kinds of information (e.g., DC coefficients, AC coefficients, different kinds of side information), and can choose from among multiple code tables within a particular coding technique.

The entropy coder 980 provides compressed video information 995 to the multiplexer [“MUX”] 990. The MUX 990 may include a buffer, and a buffer level indicator may be fed back to bit rate adaptive modules for rate control. Before or after the MUX 990, the compressed video information 995 can be channel coded for transmission over the network. The channel coding can apply error detection and correction data to the compressed video information 995.

C. Video Decoder

FIG. 10 is a block diagram of a general video decoder system 1000. The decoder system 1000 receives information 1095 for a compressed sequence of video pictures and produces output including a reconstructed picture 1005. Particular embodiments of video decoders typically use a variation or supplemented version of the generalized decoder 1000.

The decoder system 1000 decompresses predicted pictures and key pictures. For the sake of presentation, FIG. 10 shows a path for key pictures through the decoder system 1000 and a path for forward-predicted pictures. Many of the components of the decoder system 1000 are used for decompressing both key pictures and predicted pictures. The exact operations performed by those components can vary depending on the type of information being decompressed.

A DEMUX 1090 receives the information 1095 for the compressed video sequence and makes the received information available to the entropy decoder 1080. The DEMUX 1090 may include a jitter buffer and other buffers as well. Before or after the DEMUX 1090, the compressed video information can be channel decoded and processed for error detection and correction.

The entropy decoder 1080 entropy decodes entropy-coded quantized data as well as entropy-coded side information (e.g., for motion information 1015, quantization step size), typically applying the inverse of the entropy encoding performed in the encoder. Entropy decoding techniques include arithmetic decoding, differential decoding, Huffman decoding, run length decoding, LZ decoding, dictionary decoding, and combinations of the above. The entropy decoder 1080 typically uses different decoding techniques for different kinds of information (e.g., DC coefficients, AC coefficients, different kinds of side information), and can choose from among multiple code tables within a particular decoding technique.

The decoder 1000 decodes the motion information 1015 by, for example, computing one or more predictors for motion vectors, entropy decoding differential motion vectors, and combining decoded differential motion vectors with predictors to reconstruct motion vectors. Various techniques for computing motion vector predictors, computing differential motion vectors, and reconstructing motion vectors for interlaced P-fields are described below.

A motion compensator 1030 applies the motion information 1015 to one or more reference pictures 1025 to form a prediction 1035 of the picture 1005 being reconstructed. For example, the motion compensator 1030 uses one or more macroblock motion vectors to find macroblock(s) in the reference picture(s) 1025. One or more picture stores (e.g., picture stores 1020, 1022) store previous reconstructed pictures for use as reference pictures. Typically, B-pictures have more than one reference picture (e.g., at least one temporally previous reference picture and at least one temporally future reference picture). Accordingly, the decoder system 1000 can use separate picture stores 1020 and 1022 for backward and forward reference pictures. The motion compensator 1030 can compensate for motion at pixel, ½ pixel, ¼ pixel, or other increments, and can switch the resolution of the motion compensation on a picture-by-picture basis or other basis. The resolution of the motion compensation can be the same or different horizontally and vertically. Alternatively, a motion compensator applies another type of motion compensation. The prediction by the motion compensator is rarely perfect, so the decoder 1000 also reconstructs prediction residuals.

An inverse quantizer 1070 inverse quantizes entropy-decoded data. In general, the inverse quantizer applies uniform, scalar inverse quantization to the entropy-decoded data with a step-size that varies on a picture-by-picture basis or other basis. Alternatively, the inverse quantizer applies another type of inverse quantization to the data, for example, a non-uniform, vector, or non-adaptive quantization, or directly inverse quantizes spatial domain data in a decoder system that does not use inverse frequency transformations.

An inverse frequency transformer 1060 converts the quantized, frequency domain data into spatial domain video information. For block-based video pictures, the inverse frequency transformer 1060 applies an inverse DCT [“IDCT”], variant of IDCT, or other inverse block transform to blocks of the frequency transform coefficients, producing pixel data or prediction residual data for key pictures or predicted pictures, respectively. Alternatively, the inverse frequency transformer 1060 applies another conventional inverse frequency transform such as an inverse Fourier transform or uses wavelet or sub-band synthesis. The inverse frequency transformer 1060 may apply an 8×8, 8×4, 4×8, 4×4, or other size inverse frequency transform.

For a predicted picture, the decoder 1000 combines the reconstructed prediction residual 1045 with the motion compensated prediction 1035 to form the reconstructed picture 1005. When the decoder needs a reconstructed picture 1005 for subsequent motion compensation, one of the picture stores (e.g., picture store 1020) buffers the reconstructed picture 1005 for use in predicting the next picture. In some embodiments, the decoder 1000 applies a de-blocking filter to the reconstructed picture to adaptively smooth discontinuities in the picture.

III. Motion Vector Prediction

Motion vectors for macroblocks (or blocks) can be used to predict the motion vectors in a causal neighborhood of those macroblocks (or blocks). For example, an encoder/decoder can select a motion vector predictor for a current macroblock from among the motion vectors for neighboring candidate macroblocks, and predictively encode the motion vector for the current macroblock using the motion vector predictor. An encoder/decoder can use median-of-three prediction, median-of-four prediction, or some other technique to determine the motion vector predictor for the current macroblock from among candidate motion vectors from neighboring macroblocks. A procedure for median-of-three prediction is described in pseudo-code 1300 in FIG. 13. A procedure for median-of-four prediction is described in pseudo-code 1400 in FIG. 14.

IV. Field Coding for Interlaced Pictures

A typical interlaced video frame consists of two fields (e.g., a top field and a bottom field) scanned at different times. In general, it is more efficient to encode stationary regions of an interlaced video frame by coding fields together (“frame mode” coding). On the other hand, it is often more efficient to code moving regions of an interlaced video frame by coding fields separately (“field mode” coding), because the two fields tend to have different motion. A forward-predicted interlaced video frame may be coded as two separate forward-predicted fields—interlaced P-fields. Coding fields separately for a forward-predicted interlaced video frame may be efficient, for example, when there is high motion throughout the interlaced video frame, and hence much difference between the fields.

A. Reference Fields for Interlaced P-Fields

Interlaced P-fields reference one or more other fields (typically previous fields, which may or may not be coded in a bitstream). For example, in some implementations an interlaced P-field may have one or two reference fields. If the interlaced P-field has two reference fields, a particular motion vector for a block or macroblock of the P-field refers to a selected one of the two reference fields. FIGS. 15 and 16 show examples of interlaced P-fields having two reference fields. In FIG. 15, current field 1510 refers to a top field 1520 and bottom field 1530 in a temporally previous frame. Since fields 1540 and 1550 are interlaced B-fields, they are not used as reference fields. In FIG. 16, current field 1610 refers to a top field 1620 and bottom field 1630 in a predicted frame immediately previous to the interlaced video frame containing the current field 1610. In other cases, an interlaced P-field references a single field, for example, the most recent or second most recent I-field or P-field.

Alternatively, interlaced P-fields may use fields from other fields from frames of different types or temporal positions as reference fields.

B. Field Picture Coordinate System and Field Polarities

Motion vector units can be expressed in pixel/sub-pixel units or field units. For example, if the vertical component of a motion vector indicates a displacement of six quarter-pixel units, this indicates a displacement of one and a half field lines, because each line in the field in one pixel high.

FIG. 17 shows a relationship between vertical components of motion vectors and spatial locations in one implementation. The example shown in FIG. 17 shows three different scenarios 1710, 1720 and 1730 for three different combinations of current and reference field types (e.g., top and bottom). If the field types are different for the current and reference fields, the polarity is “opposite.” If the field types are the same, the polarity is “same.” For each scenario, FIG. 17 shows one vertical column of pixels in a current field and a second vertical column of pixels in a reference field. In reality, the two columns are horizontally aligned. A circle represents an actual integer-pixel position and an X represents an interpolated half or quarter-pixel position. Horizontal component values (not shown) need not account for any offset due to interlacing, as the respective fields are horizontally aligned. Negative values indicate offsets further above, and in the opposite direction, as the positive value vertical offsets shown.

In scenario 1710, the polarity is “opposite.” The current field is a top field and the reference field is a bottom field. Relative to the current field, the position of the reference field is offset by a half pixel in the downward direction due to the interlacing. Thus, a vertical motion vector component value of 0 represents a position in the reference field that is offset by a half pixel below the location in the current field, as a default “no motion” value. A vertical component value of +2 represents a position offset by a full pixel (in absolute terms) below the location in the current field, which is an interpolated value in the reference field, and a vertical component of +4 represents a position offset by one and a half pixels (in absolute terms) below the location in the current field, which is an actual value in the reference field.

In scenario 1720, the polarity is also “opposite.” The current field is a bottom field and the reference field is a top field. Relative to the current field, the position of the reference field is offset by a half pixel in the upward direction due to the interlacing. Thus, a vertical motion vector component of 0 represents a position in the reference field that is a half pixel (in absolute terms) above the location in the current field, a vertical component value of +2 represents a position at the same level (in absolute terms) as the location in the current field, and a vertical component of +4 represents a position offset by a half pixel below (in absolute terms) the location in the current field.

In scenario 1730, the polarity is “same,” and no vertical offset is applied because the position of the current field is the same relative to the reference field.

Alternatively, displacements for motion vectors are expressed according to a different convention.

V. Innovations in Motion Vector Prediction for Predictive Coding/Decoding of Interlaced P-Fields

Described embodiments include techniques and tools for coding and decoding interlaced video (e.g., interlaced P-fields). The described techniques and tools can be used in combination with one another or with other techniques and tools, or can be used independently.

In particular, described techniques and tools specify, for example, ways to generate motion vector predictors for blocks and/or macroblocks of interlace P-fields that use two fields as references for motion compensated prediction coding. Described techniques and tools implement one or more innovations, which include but are not limited to the following:

-   -   1. Generating two motion vector predictors—one for the even         field reference and one for the odd field reference. Each         predictor is derived from three previously coded, candidate         neighboring motion vectors.     -   2. Using the motion vector predictor from the same reference         field as the current motion vector (both refer to the same         reference field).     -   3. Scaling actual motion vector predictor candidate values for         one field to generate motion vector predictor candidates for the         other field for motion vector prediction.     -   4. Using a scaling operation that uses the relative temporal         distances between the current field and the two reference fields         to derive a motion vector predictor candidate for one reference         polarity from the existing motion vector predictor candidate of         the other polarity.

In interlaced video, fields may be coded using no motion prediction (intra or I fields), using forward motion prediction (P-fields) or using bi-directional prediction (B fields). Described techniques and tools involve computing motion vector predictors for portions of interlaced P-fields, in particular, in cases where the motion compensation can occur with reference to either of the two most recent (in display order) I- or P-fields. It is assumed that the two reference fields are of opposite polarities, meaning that one reference field represents odd lines of an interlaced video frame and the other reference field represents even lines of the same or different interlaced video frame. This is the case for the signaling protocol indicated in FIG. 24, which shows a syntax element (FPTYPE) for field picture type for an interlaced picture. Or, for example, referring again to FIG. 15, current field 1510 refers to a top field 1520 and a bottom field 1530, which represent the odd and even lines, respectively, of a video frame.

A. Motion Vector Prediction in Two-Reference Field Pictures

With two-reference field P-fields, a current field can reference two fields in the same temporal direction (e.g., the two most recent previous reference fields). In the case of a two-reference field interlaced P-field, the encoder and decoder select between two motion vector predictors for a motion vector of a block or macroblock. In some embodiments, one predictor is for a reference field of same polarity as the current field, and the other is for a reference field of opposite polarity. Other combinations of polarities also are possible.

In some embodiments, an encoder/decoder calculates a motion vector predictor for a current block or macroblock by finding an odd field predictor and an even field predictor, and selecting one of the predictors to process the macroblock. For example, FIG. 18 shows a technique 1800 for calculating a motion vector predictor for a block or macroblock of an interlaced P-field having two possible reference fields.

At 1810, an encoder/decoder determines an odd field motion vector predictor and even field motion vector predictor. One of the motion vector predictors thus has the same polarity as the current field, and the other motion vector predictor has the opposite polarity.

At 1820, the encoder/decoder selects a motion vector predictor from among the odd field motion vector predictor and the even field motion vector predictor. For example, the encoder selects between the motion vector predictors based upon which gives better prediction. Or, the encoder selects the motion vector predictor that refers to the same reference field as the motion vector that is currently being predicted. The encoder signals which motion vector predictor to use using a simple selection signal or using more complex signaling that incorporates contextual information to improve coding efficiency. The contextual information may indicate which of the odd field or even field, or which of the same polarity field or opposite polarity field, has been used predominately in the neighborhood around the block or macroblock. The decoder selects which motion vector predictor to use based upon the selection signal and/or the contextual information.

At 1830, the encoder/decoder processes the motion vector using the selected motion vector predictor. For example, the encoder encodes a differential between the motion vector and the motion vector predictor. Or, the decoder decodes the motion vector by combining the motion vector differential and the motion vector predictor.

Alternatively, the encoder and/or decoder may skip determining the odd field motion vector predictor or determining the even field motion vector predictor. For example, if the encoder determines that the odd field will be used for motion compensation for a particular block or macroblock, the encoder determines only the odd field motion vector predictor. Or, if the decoder determines from contextual and/or signaled information that the odd field will be used for motion compensation, the decoder determines only the odd field motion vector predictor. In this way, the encoder and decoder may avoid unnecessary operations.

In one implementation, a decoder employs the following technique to determine motion vector predictors for a current interlaced P-field:

For each block or macroblock with a motion vector in an interlaced P-field, two sets of three candidate motion vector predictors are obtained. The positions of the neighboring macroblocks from which these candidate motion vector predictors are obtained relative to a current macroblock 1900 are shown in FIG. 19. Three of the candidates are from the even reference field and three are from the odd reference field. Since the neighboring macroblocks in each candidate direction (A, B or C) will either be intra-coded or have an actual motion vector that references either the even field or the odd field, there is a need to derive the other field's motion vector. For example, for a given macroblock, suppose predictor A has a motion vector which references the odd field. In this case, the “even field” predictor candidate A is derived from the motion vector of “odd field” predictor candidate A. This derivation is accomplished using a scaling operation. (See, for example, the explanation of FIGS. 21A and 21B below.) Alternatively, the derivation is accomplished in another manner.

Once the three odd field candidate motion vector predictors have been obtained, a median operation is used to derive an odd field motion vector predictor from the three odd field candidates. Similarly, once the three even field candidate motion vector predictors have been obtained, a median operation is used to derive an even field motion vector predictor from the three even field candidates. Alternatively, another mechanism is used to select the field motion vector predictor based upon the candidate field motion vector predictors. The decoder decides whether to use the even field or odd field as the motion vector predictor (e.g., by selecting the dominant predictor), and the even or odd motion vector predictor is used to reconstruct the motion vector.

The pseudo-code 2000 in FIGS. 20A-20F illustrates a process used to generate motion vector predictors from predictors A, B, and C as arranged in FIG. 19. While FIG. 19 shows a neighborhood for a typical macroblock in the middle of the current interlaced P-field, the pseudo-code 2000 of FIGS. 20A-20F addresses various special cases for macroblock locations. In addition, the pseudo-code 2000 may be used to compute a motion vector predictor for the motion vector of a block in various locations.

In the pseudo-code 2000, the terms “same field” and “opposite field” are to be understood relative to the field currently being coded or decoded. If the current field is an even field, for example, the “same field” is the even reference field and the “opposite field” is the odd reference field. The variables samefieldpred_x and samefieldpred_y in the pseudo-code 2000 represent the horizontal and vertical components of the motion vector predictor from the same field, and the variables oppositefieldpred_x and oppositefieldpred_y represent the horizontal and vertical components of the motion vector predictor from the opposite field. The variables samecount and oppositecount track how many of the motion vectors for the neighbors of the current block or macroblock reference the “same” polarity reference field for the current field and how many reference the “opposite” polarity reference field, respectively. The variables samecount and oppositecount are initialized to 0 at the beginning of the pseudo-code.

The scaling operations scaleforsame( ) and scaleforopposite( ) mentioned in the pseudo-code 2000 are used to derive motion vector predictor candidates for the “other” field from the actual motion vector values of the neighbors. The scaling operations are implementation-dependent. Example scaling operations are described below with reference to FIGS. 21A, 21B, 22, and 23. Alternatively, other scaling operations are used, for example, to compensate for vertical displacements such as those shown in FIG. 17.

FIGS. 20A and 20B show pseudo-code for computing a motion vector predictor for a typical internal block or macroblock. The motion vectors for “intra” neighbors are set to 0. For each neighbor, the same field motion vector predictor and opposite field motion vector predictor are set, where one is set from the actual value of the motion vector for the neighbor, and the other is derived therefrom. The median of the candidates is computed for the same field motion vector predictor and the opposite field motion vector predictor, and the “dominant” predictor is determined from samecount and oppositecount. The variable dominantpredictor indicates which field contains the dominant motion vector predictor. A motion vector predictor is dominant if it has the same polarity as more of the three candidate predictors. (The signaled value predictor_flag, which is decoded along with the motion vector differential data, indicates whether the dominant or non-dominant predictor is used.)

The pseudo-code in FIG. 20C addresses the situation of a macroblock in an interlaced P-field with only one macroblock per row, for which there are no neighbors B or C. The pseudo-code in FIGS. 20D and 20E addresses the situation of a block or macroblock at the left edge of an interlaced P-field, for which there is no neighbor C. Here, a motion vector predictor is dominant if it has the same polarity as more of the two candidate predictors, with the opposite field motion vector predictor being dominant in the case of a tie. Finally, the pseudo-code in FIG. 20F addresses, for example, the cases of macroblock in the top row of an interlaced P-field.

B. Scaling for Derivation of One Field Motion Vector Predictor from Another Field Motion Vector Predictor

In one implementation, an encoder/decoder derives one field motion vector predictor from another field motion vector predictor using the scaling operation illustrated in the pseudo-code 2100 of FIGS. 21A and 21B. The values of SCALEOPP, SCALESAME1, SCALESAME2, SCALEZONE1_X, SCALEZONE1_Y, ZONE1OFFSET_X and ZONE1OFFSET_Y are implementation dependent. Two possible sets of values are shown in table 2200 in FIG. 22 for the case where the current field is first field in the interlaced video frame, and in table 2300 in FIG. 23 for the case where the current field is the second field in the interlaced video frame. In tables 2200 and 2300, the reference frame distance is defined as the number of B-pictures (i.e., a video frame containing two B-fields) between the current field and the frame containing the temporally furthest reference field.

In the examples shown in tables 2200 and 2300, the value of N is dependant on a motion vector range. For example, an extended motion vector range can be signaled by the syntax element EXTENDED_MV=1. If EXTENDED_MV=1, the MVRANGE syntax element is present in the picture header and signals the motion vector range. If EXTENDED_MV=0 then a default motion vector range is used. Table 1 shows the relationship between N and the MVRANGE. TABLE 1 Derivation of N in FIGS. 22 and 23 MVRANGE N  0 1 or default  10 2 110 8 111 16

The values shown in tables 2200 and 2300 can be modified depending on implementation.

Alternatively, extended motion vector range information is not used, or scaling can be performed in some other way.

VI. Combined Implementations

A detailed combined implementation for a bitstream syntax and decoder are now described, in addition to an alternative combined implementation with minor differences from the main combined implementation.

A. Bitstream Syntax

In various combined implementations, data for interlaced P-fields is presented in the form of a bitstream having plural layers (e.g., sequence, frame, field, macroblock, block and/or sub-block layers). Data for each frame including an interlaced P-field consists of a frame header followed by data for the field layers. The bitstream elements that make up the frame header for a frame including an interlaced P-field are shown in FIG. 24. The bitstream elements that make up the field headers for interlaced P-fields are shown in FIG. 25. The bitstream elements that make up the macroblock layer for interlaced P-fields are shown in FIG. 26. The following sections describe selected bitstream elements in the frame, field and macroblock layers that are related to signaling for motion vector prediction for blocks or macroblocks of interlaced P-fields.

1. Selected Frame Layer Elements

FIG. 24 is a diagram showing a frame-level bitstream syntax for frames including interlaced P-fields in a combined implementation. Specific bitstream elements are described below.

Frame Coding Mode (FCM) (Variable Size)

FCM is a variable length codeword [“VLC”] used to indicate the picture coding type. FCM takes on values for frame coding modes as shown in Table 2 below: TABLE 2 Frame Coding Mode VLC FCM value Frame Coding Mode  0 Progressive 10 Frame-Interlace 11 Field-Interlace Field Picture Type (FPTYPE) (3 Bits)

FPTYPE is a three-bit syntax element present in the frame header for a frame including interlaced P-fields. FPTYPE takes on values for different combinations of field types according to Table 3 below. TABLE 3 Field Picture Type FLC FPTYPE FLC First Field Type Second Field Type 000 I I 001 I P 010 P I 011 P P 100 B B 101 B BI 110 BI B 111 BI BI P Reference Distance (REFDIST) (Variable Size)

REFDIST is a variable sized syntax element. This element indicates the number of frames between the current frame and the reference frame. Table 4 shows the a VLC used to encode the REFDIST values. TABLE 4 REFDIST VLC Table Reference VLC Codeword Frame Dist. (Binary) VLC Size 0 00 2 1 01 2 2 10 2 N 11[(N − 3) 1s]0 N

The last row in Table 4 indicates the codewords used to represent reference frame distances greater than 2. These are coded as (binary) 11 followed by N-3 1 s, where N is the reference frame distance. The last bit in the codeword is 0. For example:

-   -   N=3, VLC Codeword=110, VLC Size=3     -   N=4, VLC Codeword=1110, VLC Size=4     -   N=5, VLC Codeword=11110, VLC Size=5

In an alternative combined implementation, the picture type information is signaled at the beginning of the field level for an interlaced P-field, instead of at the frame level for the frame including the interlaced P-field, and P reference distance is omitted.

2. Selected Field Layer Elements

FIG. 25 is a diagram showing a field-level bitstream syntax for interlaced P-fields in the combined implementation. Specific bitstream elements are described below.

Number of Reference Pictures (NUMREF) (1 Bit)

The NUMREF syntax element is a one-bit syntax element that indicates whether the current field may reference one or two previous reference field pictures. If NUMREF=0, then the current P field picture may only reference one field. In this case, the REFFIELD syntax element follows in the picture layer bitstream. For an interlaced P-field with two reference fields, NUMREF=1.

Reference Field Picture Indicator (REFFIELD) (1 Bit)

REFFIELD is a 1 bit syntax element present in interlace P-field picture headers if NUMREF=0. REFFIELD indicates which previously decoded field is used as a reference. If REFFIELD=0, then the temporally closest (in display order) I or P field is used as a reference. If REFFIELD=1, then the second most temporally recent I or P field picture is used as reference.

Extended MV Range Flag (MVRANGE) (Variable Size)

MVRANGE is a variable-sized syntax element present when the sequence-layer EXTENDED_MV bit is set to 1. The MVRANGE VLC represents a motion vector range.

Extended Differential MV Range Flag (DMVRANGE) (Variable Size)

DMVRANGE is a variable sized syntax element present if the sequence level syntax element EXTENDED_DMV=1. The DMVRANGE VLC represents a motion vector differential range.

Motion Vector Mode (MVMODE) (Variable Size or 1 Bit)

The MVMODE syntax element signals one of four motion vector coding modes or one intensity compensation mode. Several subsequent elements provide additional motion vector mode and/or intensity compensation information.

Macroblock Mode Table (MBMODETAB) (2 or 3 Bits)

The MBMODETAB syntax element is a fixed length field. For interlace P-fields, MBMODETAB is a 3 bit value that indicates which one of the eight Huffman tables is used to decode the macroblock mode syntax element (MBMODE) in the macroblock layer.

Motion Vector Table (MVTAB) (2 or 3 Bits)

The MVTAB syntax element is a 2 or 3 bit value. For interlace P-fields in which NUMREF=1, MVTAB is a 3 bit syntax element that indicates which of eight interlace Huffman tables are used to decode the motion vector data.

4MV Block Pattern Table (4MVBPTAB) (2 Bits)

The 4MVBPTAB syntax element is a 2 bit value. For interlace P-fields, it is only present if MVMODE (or MVMODE2, if MVMODE is set to intensity compensation) indicates that the picture is of “Mixed MV” type. The 4MVBPTAB syntax element signals which of four Huffman tables is used to decode the 4MV block pattern (4MVBP) syntax element in 4MV macroblocks.

3. Selected Macroblock Layer Elements

FIG. 26 is a diagram showing a macroblock-level bitstream syntax for interlaced P-fields in the combined implementation. Specific bitstream elements are described below. Data for a macroblock consists of a macroblock header followed by block layer data.

Macroblock Mode (MBMODE) (Variable Size)

The MBMODE syntax element indicates the macroblock type (1MV, 4MV or Intra) and also the presence of the CBP flag and motion vector data, as described in detail in Section VI.B.3. below.

Motion Vector Data (MVDATA) (Variable Size)

MVDATA is a variable sized syntax element that encodes differentials for the motion vector(s) for the macroblock, the decoding of which is described in detail in Section VI.B.3. below.

4MV Block Pattern (4MVBP) (4 Bits)

The 4MVBP syntax element indicates which of the 4 luminance blocks contain non-zero motion vector differentials, the use of which is described in detail in Section VI.B.3. below.

Block-level Motion Vector Data (BLKMVDATA) (Variable Size)

BLKMVDATA is a variable-size syntax element that contains motion information for the block, and is present in 4MV macroblocks.

Hybrid Motion Vector Prediction (HYBRIDPRED) (1 Bit)

HYBRIDPRED is a 1-bit syntax element per motion vector. If the predictor is explicitly coded in the bitstream, a bit is present that indicates whether to use predictor A or predictor C as the motion vector predictor.

B. Decoding Interlaced P-fields

The following sections describe a process for decoding interlaced P-fields in the combined implementation.

1. Frame/Field Layer Decoding

Reference Pictures

A P-field Picture may reference either one or two previously decoded fields. The NUMREF syntax element in the picture layer is a one-bit syntax element that indicates whether the current field may reference one or two previous reference field pictures. If NUMREF=0, then the blocks and macroblocks of a current interlaced P-field picture may only reference one field. If NUMREF=1, then the blocks and macroblocks of the current interlaced P-field picture may use either of the two temporally closest (in display order) I or P field pictures as a reference.

FIG. 15 and 16 show examples of two-reference P-fields.

P-field Picture Types

Interlaced P-field pictures may be one of two types: 1MV or Mixed-MV. The following sections describe each type. In 1MV P-fields, a single motion vector is used per motion-compensated macroblock to indicate the displacement of the predicted blocks for all 6 blocks in the macroblock. The 1MV mode is signaled by the MVMODE and MVMODE2 picture layer syntax elements.

In Mixed-MV P-fields, each motion-compensated macroblock may be encoded as a 1MV or a 4MV macroblock. In a 4MV macroblock, each of the 4 luminance blocks has a motion vector associated with it. In a Mixed-MV P-field, the 1MV or 4MV mode for each macroblock is indicated by the MBMODE syntax element at every macroblock. The Mixed-MV mode is signaled by the MVMODE and MVMODE2 picture layer syntax elements.

2. Macroblock Layer Decoding

Macroblocks in interlaced P-field pictures may be one of 3 possible types: 1MV, 4MV, and Intra. The macroblock type is signaled by the MBMODE syntax element in the macroblock layer. The following sections describe the 1MV and 4MV types and how they are signaled.

1MV Macroblocks

1MV macroblocks may occur in 1MV and Mixed-MV P-field pictures. A 1MV macroblock is one where a single motion vector represents the displacement between the current and reference pictures for all 6 blocks in the macroblock. For a 1MV macroblock, the MBMODE syntax element in the macroblock layer indicates three things:

-   -   1) That the macroblock type is 1MV     -   2) Whether the CBPCY syntax element is present     -   3) Whether the MVDATA syntax element is present

If the MBMODE syntax element indicates that the CBPCY syntax element is present, then the CBPCY syntax element is present in the macroblock layer in the corresponding position. The CBPCY indicates which of the 6 blocks are coded in the block layer. If the MBMODE syntax element indicates that the CBPCY syntax element is not present, then CBPCY is assumed to equal 0 and no block data is present for any of the 6 blocks in the macroblock.

If the MBMODE syntax element indicates that the MVDATA syntax element is present, then the MVDATA syntax element is present in the macroblock layer in the corresponding position. The MVDATA syntax element encodes the motion vector differential. The motion vector differential is combined with the motion vector predictor to reconstruct the motion vector. If the MBMODE syntax element indicates that the MVDATA syntax element is not present, then the motion vector differential is assumed to be zero and therefore the motion vector is equal to the motion vector predictor.

4MV Macroblocks

4MV macroblocks may only occur in Mixed-MV P-field pictures. A 4MV macroblock is one where each of the 4 luminance blocks in a macroblock has an associated motion vector which indicates the displacement between the current and reference pictures for that block. The displacement for the chroma blocks is derived from the 4 luminance motion vectors.

For a 4MV macroblock, the MBMODE syntax element in the macroblock layer indicates three things:

-   -   1) That the macroblock type is 4MV     -   2) Whether the CBPCY syntax element is present

The 4MVBP syntax element indicates which of the 4 luminance blocks contain non-zero motion vector differentials. The 4MVBP syntax element decodes to a value between 0 and 15. For each of the 4 bit positions in the 4MVBP, a value of 0 indicates that no motion vector differential (BLKMVDATA) is present for that block and the motion vector differential is assumed to be 0. A value of 1 indicates that a motion vector differential (BLKMVDATA) is present for that block in the corresponding position. For example, if 4MVBP decodes to a value of 1100 (binary), then the bitstream contains BLKMVDATA for blocks 0 and 1 and no BLKMVDATA is present for blocks 2 and 3.

In an alternative implementation, the MBMODE syntax element can indicate if whether the 4MVBP syntax element is present; if the MBMODE syntax element indicates that the 4MVBP syntax element is not present, then it is assumed that motion vector differential data (BLKMVDATA) is present for all 4 luminance blocks.

Depending on whether the MVMODE/MVMODE2 syntax element indicates mixed-MV or all-1MV the MBMODE signals the information as follows. Table 5 shows how the MBMODE signals information about the macroblock in all-1MV pictures. TABLE 5 Macroblock Mode in All-1MV Pictures Index Macroblock Type CBP Present MV Present 0 Intra No NA 1 Intra Yes NA 2 1MV No No 3 1MV No Yes 4 1MV Yes No 5 1MV Yes Yes

Table 6 shows how the MBMODE signals information about the macroblock in mixed-MV pictures. TABLE 6 Macroblock Mode in Mixed-1MV Pictures Index Macroblock Type CBP Present MV Present 0 Intra No NA 1 Intra Yes NA 2 1MV No No 3 1MV No Yes 4 1MV Yes No 5 1MV Yes Yes 6 4MV No NA 7 4MV Yes NA

One of 8 tables is used to signal the MBMODE. The table is signaled at the picture layer via the MBMODETAB syntax element.

3. Motion Vector Decoding Process

The following sections describe the motion vector decoding process for blocks and macroblocks of P-field pictures.

Decoding Motion Vector Differential

The MVDATA or BLKMVDATA syntax elements encode motion information for macroblocks or the blocks in the macroblock. 1MV macroblocks have a single MVDATA syntax element, and 4MV macroblocks may have between zero and four BLKMVDATA elements. The following sections describe how to compute the motion vector differential for the one-reference (picture layer syntax element NUMREF=0) and two-reference (picture layer syntax element NUMREF=1) cases.

Motion Vector Differentials in One-Reference Field Pictures

In field pictures that have only one reference field, each MVDATA or BLKMVDATA syntax element in the macroblock layer jointly encodes two things: 1) the horizontal motion vector differential component and 2) the vertical motion vector differential component.

The MVDATA or BLKMVDATA syntax element is a variable length Huffman codeword followed by a fixed length codeword. The value of the Huffman codeword determines the size of the fixed length codeword. The MVTAB syntax element in the picture layer specifies the Huffman table used to decode the variable sized codeword.

The pseudo-code 2700 in FIG. 27A illustrates how the motion vector differential is decoded for a one-reference field. The values dmv_x and dmv_y are computed in the pseudo-code 2700. The values are defined as follows:

-   -   dmv_x: differential horizontal motion vector component,     -   dmv_y: differential vertical motion vector component,     -   k_x, k_y: fixed length for long motion vectors,

k_x and k_y depend on the motion vector range as defined by the MVRANGE symbol. TABLE 7 k_x and k_y specified by MVRANGE MVRANGE k_x k_y range_x range_y  0 9 8 256 128 (default)  10 10 9 512 256 110 12 10 2048 512 111 13 11 4096 1024

-   -   extend_x: extended range for horizontal motion vector         differential,     -   extend_y: extended range for vertical motion vector         differential,     -   extend_x and extend_y are derived from the DMVRANGE picture         field syntax element. If DMVRANGE indicates that extended range         for the horizontal component is used, then extend_x=1. Otherwise         extend_x=0. Similarly, if DMVRANGE indicates that extended range         for the vertical component is used, then extend_y=1 otherwise         extend_y=0.

The offset_table is an array used in the pseudo-code 2700 and is defined as shown in FIG. 27A.

The pseudo-code 2710 in FIG. 27B illustrates how the motion vector differential is decoded for a one-reference field in an alternative combined implementation. Pseudo-code 2710 decodes motion vector differentials in a different way. For example, pseudo-code 2710 omits handling of extended motion vector differential ranges.

Motion Vector Differentials in Two-Reference Field Pictures

Two-reference field pictures occur in the coding of interlace frames using field pictures. Each frame of the sequence is separated into two fields, and each field is coded using what is essentially the progressive code path. Field pictures often have two reference fields and the coding of field picture motion vectors in this case is described below.

In field pictures that have two reference fields, each MVDATA or BLKMVDATA syntax element in the macroblock layer jointly encodes three things: 1) the horizontal motion vector differential component, 2) the vertical motion vector differential component and 3) whether the dominant or non-dominant predictor is used, i.e., which of the two fields is referenced by the motion vector.

The MVDATA or BLKMVDATA syntax element is a variable length Huffman codeword followed by a fixed length codeword. The value of the Huffman codeword determines the size of the fixed length codeword. The MVTAB syntax element in the picture layer specifies the Huffman table used to decode the variable sized codeword. The pseudo-code 2800 in FIG. 28A illustrates how the motion vector differential, and dominant/non-dominant predictor information are decoded.

The values predictor_flag, dmv_x and dmv_y are computed in the pseudo-code 2800 in FIG. 28A. In addition to the variables and arrays shown in the pseudo-code 2700 in FIG. 27A, pseudo-code 2800 contains the variable predictor_flag, which is a binary flag indicating whether the dominant or non-dominant motion vector predictor is used (0=dominant predictor used, 1=non-dominant predictor used), and the table size_table, which is an array defined as shown in FIG. 28.

The pseudo-code 2810 in FIG. 28B illustrates how the motion vector differential is decoded for a two-reference field in an alternative combined implementation. Pseudo-code 2810 decodes motion vector differentials in a different way. For example, pseudo-code 2810 omits handling of extended motion vector differential ranges.

Motion Vector Predictors

Motion vectors are computed by adding the motion vector differential computed in the previous section to a motion vector predictor. The predictor is computed from up to three neighboring motion vectors. The following sections describe how the motion vector predictors are calculated for macroblocks in 1MV P-field pictures and Mixed-MV P-field pictures in this combined implementation.

Motion Vector Predictors in 1MV Interlaced P-Fields

FIGS. 29A and 29B are diagrams showing the locations of macroblocks considered for candidate motion vector predictors for a 1MV macroblock in an interlaced P-field. In 1MV interlaced P-fields, the candidate predictors are taken from the left, top and top-right macroblocks, except in the case where the macroblock is the last macroblock in the row. In this case, Predictor B is taken from the top-left macroblock instead of the top-right. For the special case where the frame is one macroblock wide, the predictor is always Predictor A (the top predictor). The special cases for the current macroblock being in the top row (with no A and B predictors, or with no predictors at all) are addressed above with reference to FIGS. 20A-20F.

Motion Vector Predictors In Mixed-MV P Pictures

FIGS. 30A-34 show the locations of the blocks or macroblocks considered for the up to 3 candidate motion vectors for a motion vector for a 1MV or 4MV macroblock in Mixed-MV P-field pictures. In the following figures, the larger squares are macroblock boundaries and the smaller squares are block boundaries. For the special case where the frame is one macroblock wide, the predictor is always Predictor A (the top predictor). The special cases for the current block or macroblock being in the top row are addressed above with reference to FIGS. 20A-20F.

FIGS. 30A and 30B are diagrams showing locations of blocks considered for candidate motion vector predictors for a 1MV current macroblock in a mixed 1MV/4MV interlaced P-field. The neighboring macroblocks may be 1MV or 4MV macroblocks. FIGS. 30A and 30B show the locations for the candidate motion vectors assuming the neighbors are 4MV (i.e., predictor A is the motion vector for block 2 in the macroblock above the current macroblock, and predictor C is the motion vector for block 1 in the macroblock immediately to the left of the current macroblock). If any of the neighbors is a 1MV macroblock, then the motion vector predictor shown in FIGS. 29A and 29B is taken to be the vector for the entire macroblock. As FIG. 30B shows, if the macroblock is the last macroblock in the row, then Predictor B is from block 3 of the top-left macroblock instead of from block 2 in the top-right macroblock as is the case otherwise.

FIGS. 31A-34 show the locations of blocks considered for candidate motion vector predictors for each of the 4 luminance blocks in a 4MV macroblock. FIGS. 31A and 31B are diagrams showing the locations of blocks considered for candidate motion vector predictors for a block at position 0 in a 4MV macroblock in a mixed 1MV/4MV interlaced P-field; FIGS. 32A and 32B are diagrams showing the locations of blocks considered for candidate motion vector predictors for a block at position 1 in a 4MV macroblock in a mixed interlaced P-field; FIG. 33 is a diagram showing the locations of blocks considered for candidate motion vector predictors for a block at position 2 in a 4MV macroblock in a mixed 1MV/4MV interlaced P-field; and FIG. 34 is a diagram showing the locations of blocks considered for candidate motion vector predictors for a block at position 3 in a 4MV macroblock in a mixed 1MV/4MV interlaced P-field. Again, if a neighbor is a 1MV macroblock, the motion vector predictor for the macroblock is used for the blocks of the macroblock.

For the case where the macroblock is the first macroblock in the row, Predictor B for block 0 is handled differently than block 0 the remaining macroblocks in the row. In this case, Predictor B is taken from block 3 in the macroblock immediately above the current macroblock instead of from block 3 in the macroblock above and to the left of current macroblock, as is the case otherwise. Similarly, for the case where the macroblock is the last macroblock in the row, Predictor B for block 1 is handled differently. In this case, the predictor is taken from block 2 in the macroblock immediately above the current macroblock instead of from block 2 in the macroblock above and to the right of the current macroblock, as is the case otherwise. If the macroblock is in the first macroblock column, then Predictor C for blocks 0 and 2 are set equal to 0.

Dominant and Non-Dominant MV Predictors

In two-reference field P-field pictures, for each inter-coded macroblock, two motion vector predictors are derived. One is from the dominant field and the other is from the non-dominant field. The dominant field is considered to be the field containing the majority of the actual-value motion vector predictor candidates in the neighborhood. In the case of a tie, the motion vector predictor for the opposite field is considered to be the dominant predictor. Intra-coded macroblocks are not considered in the calculation of the dominant/non-dominant predictor. If all candidate predictor macroblocks are intra-coded, then the dominant and non-dominant motion vector predictors are set to zero and the dominant predictor is taken to be from the opposite field.

Calculating the Motion Vector Predictor

If NUMREF=1, then the current field picture may refer to the two most recent field pictures, and two motion vector predictors are calculated for each motion vector of a block or macroblock. The pseudo-code 3500 in FIGS. 35A-35F describes how the motion vector predictors are calculated for the two-reference case in the combined implementation. (The pseudo-code 2000 in FIGS. 20A-20F describes how the motion vector predictors are calculated for the two-reference case in another implementation). In two-reference pictures (NUMREF=1) the current field may reference the two most recent fields. One predictor is for the reference field of the same polarity and the other is for the reference field with the opposite polarity.

Scaling Operations in Combined Implementation

FIGS. 21A-B are code diagrams showing pseudo-code 2100 for scaling a predictor from one field to derive a predictor from another field. The values of SCALEOPP, SCALESAME1, SCALESAME2, SCALEZONE1_X, SCALEZONE1_Y, ZONE1OFFSET_X and ZONE1OFFSET_Y in this combined implementation are shown in the table 2200 in FIG. 22 (for the case where the current field is the first field) and the table 2300 in FIG. 23 (for the case where the current field is the second field). The reference frame distance is encoded in the REFDIST field in the picture header. The reference frame distance is REFDIST+1.

Reconstructing Motion Vectors

The following sections describe how to reconstruct the luminance and chroma motion vectors for 1MV and 4MV macroblocks. After a motion vector is reconstructed, it may be subsequently used as a neighborhood motion vector to predict the motion vector for a nearby macroblock. If the motion vector is for a block or macroblock in a two-reference field interlaced P-field, the motion vector will have an associated polarity of “same” or “opposite,” and may be used to derive a motion vector predictor for the other field polarity for motion vector prediction.

Luminance Motion Vector Reconstruction

In all cases (1MV and 4MV macroblocks) the luminance motion vector is reconstructed by adding the differential to the predictor as follows: mv _(—) x=(dmv _(—) x+predictor_(—) x)smod range_(—) x mv _(—) y=(dmv _(—) y+predictor_(—) y)smod range_(—) y

The modulus operation “smod” is a signed modulus, defined as follows: A smod b=((A+b) % (2*b))−b

This ensures that the reconstructed vectors are valid. (A smod b) lies within −b and b−1. range_x and range_y depend on MVRANGE.

If the interlaced P-field picture uses two reference pictures (NUMREF=1), then the predictor_flag derived after decoding the motion vector differential is combined with the value of dominantpredictor derived from motion vector prediction to determine which field is used as reference. The pseudo-code 3600 in FIG. 36 describes how the reference field is determined.

In 1MV macroblocks there will be a single motion vector for the 4 blocks that make up the luminance component of the macroblock. If the MBMODE syntax element indicates that no MV data is present in the macroblock layer, then dmv_x=0 and dmv_y=0 (mv_x=predictor_x and mv_y=predictor_y).

In 4MV macroblocks, each of the inter-coded luminance blocks in a macroblock will have its own motion vector. Therefore there will be between 0 and 4 luminance motion vectors in each 4MV macroblock. If the 4MVBP syntax element indicates that no motion vector information is present for a block, then dmv_x=0 and dmv_y for that block (mv_x=predictor_x and mv_y=predictor_y).

Chroma Motion Vector Reconstruction

The chroma motion vectors are derived from the luminance motion vectors. In an alternative implementation, for 4MV macroblocks, the decision on whether to code the chroma blocks as Inter or Intra is made based on the status of the luminance blocks or fields.

Having described and illustrated the principles of my invention with reference to various embodiments, it will be recognized that the various embodiments can be modified in arrangement and detail without departing from such principles. It should be understood that the programs, processes, or methods described herein are not related or limited to any particular type of computing environment, unless indicated otherwise. Various types of general purpose or specialized computing environments may be used with or perform operations in accordance with the teachings described herein. Elements of embodiments shown in software may be implemented in hardware and vice versa.

In view of the many possible embodiments to which the principles of my invention may be applied, I claim as my invention all such embodiments as may come within the scope and spirit of the following claims and equivalents thereto. 

1. A method comprising: computing a motion vector predictor for a motion vector for a portion of an interlaced P-field, including selecting between using a same polarity motion vector predictor or using an opposite polarity motion vector predictor for the portion; and processing the motion vector based at least in part on the motion vector predictor computed for the motion vector.
 2. The method of claim 1 wherein the processing comprises computing a motion vector differential between the motion vector and the motion vector predictor during encoding.
 3. The method of claim 1 wherein the processing comprises reconstructing the motion vector from a motion vector differential and the motion vector predictor during decoding.
 4. The method of claim 1 wherein the portion is a macroblock.
 5. The method of claim 1 wherein the portion is a block of a macroblock.
 6. The method of claim 1 wherein the selecting is based at least in part on a count of opposite polarity motion vectors for a neighborhood around the portion and/or a count of same polarity motion vectors for the neighborhood.
 7. The method of claim 1 wherein the selecting is based at least in part on a single bit signal in a bit stream.
 8. The method of claim 1 wherein the selecting comprises: determining a dominant predictor based at least in part on a count of opposite polarity motion vectors for a neighborhood around the portion and/or a count of same polarity motion vectors for the neighborhood; and selecting the same polarity motion vector predictor or the opposite polarity motion vector predictor based upon the dominant predictor and a single bit signal in a bit stream.
 9. The method of claim 1 wherein the selecting comprises: selecting the same polarity motion vector predictor if the motion vector for the portion refers to a same polarity field, or selecting the opposite polarity motion vector predictor if the motion vector for the portion refers to an opposite polarity field.
 10. The method of claim 1 further comprising computing the same polarity motion vector predictor as a median of plural same polarity motion vector predictor candidates for a neighborhood around the portion.
 11. The method of claim 10 wherein at least one of the plural same polarity motion vector predictor candidates is derived by scaling an opposite polarity motion vector predictor candidate.
 12. The method of claim 1 further comprising computing the opposite polarity motion vector predictor as a median of plural opposite polarity motion vector predictor candidates for a neighborhood around the portion.
 13. The method of claim 12 wherein at least one of the plural opposite polarity motion vector predictor candidates is derived by scaling a same polarity motion vector predictor candidate.
 14. The method of claim 1 further comprising repeating the computing and the processing for each of plural other portions of the interlaced P-field.
 15. A method comprising: computing a motion vector predictor for a motion vector for a portion of an interlaced P-field based at least in part on plural neighboring motion vectors, wherein the plural neighboring motion vectors include one or more opposite polarity motion vectors and one or more same polarity motion vectors; and processing the motion vector based at least in part on the motion vector predictor computed for the motion vector.
 16. The method of claim 15 wherein the processing comprises computing a motion vector differential between the motion vector and the motion vector predictor during encoding.
 17. The method of claim 15 wherein the processing comprises reconstructing the motion vector from a motion vector differential and the motion vector predictor during decoding.
 18. The method of claim 15 wherein the portion is a macroblock.
 19. The method of claim 15 wherein the portion is a block of a macroblock.
 20. The method of claim 15 further comprising computing a same polarity motion vector predictor as a median of plural same polarity motion vector predictor candidates, wherein at least one of the plural candidates is derived based at least in part on scaling a value from one of the one or more opposite polarity motion vectors.
 21. The method of claim 15 further comprising computing an opposite polarity motion vector predictor as a median of plural opposite polarity motion vector predictor candidates, wherein at least one of the plural candidates is derived based at least in part on scaling a value from one of the one or more same polarity motion vectors
 22. A method of processing an interlaced predicted video frame, the method comprising: determining a first set of motion vector predictor candidates for a macroblock in a current field in the video frame, the first set of motion vector predictor candidates referencing a first reference field having a same polarity relative to the current field; computing a first motion vector predictor for the macroblock based at least in part on one or more of the first set of motion vector predictor candidates; determining a second set of motion vector predictor candidates for the macroblock, the second set of motion vector predictor candidates referencing a second reference field having an opposite polarity relative to the current field; computing a second motion vector predictor for the macroblock based at least in part on one or more of the second set of motion vector predictor candidates; and using the first and second motion vector predictors in the processing.
 23. The method of claim 22 wherein the using the first and second motion vector predictors comprises selecting one of the first and second motion vector predictors and calculating a motion vector differential for the macroblock based on the selected motion vector predictor, the method further comprising entropy coding the motion vector differential.
 24. The method of claim 22 further comprising entropy decoding a motion vector differential for the macroblock, wherein using the first and second motion vector predictors includes selecting one of the first and second motion vector predictors and combining the selected predictor with the motion vector differential to reconstruct a motion vector for the macroblock.
 25. A computer-readable medium having stored thereon computer-executable instructions for performing the method of claim 22 in a video encoder.
 26. A computer-readable medium having stored thereon computer-executable instructions for performing the method of claim 22 in a video decoder.
 27. A method comprising: computing a first polarity motion vector predictor candidate by scaling an actual motion vector value having a second polarity different than the first polarity; and using the first polarity motion vector predictor candidate when computing a motion vector predictor for a motion vector for a portion of an interlaced P-field.
 28. The method of claim 27 further comprising computing a motion vector differential between the motion vector and the motion vector predictor during encoding.
 29. The method of claim 27 further comprising reconstructing the motion vector from a motion vector differential and the motion vector predictor during decoding.
 30. The method of claim 27 wherein the portion is a macroblock.
 31. The method of claim 27 wherein the portion is a block of a macroblock.
 32. The method of claim 27 wherein the first polarity motion vector predictor candidate has the opposite field polarity as the portion, wherein the actual motion vector value has the same field polarity as the portion, and wherein the scaling is adapted to scale from the same polarity to the opposite polarity.
 33. The method of claim 27 wherein the first polarity motion vector predictor candidate has the same field polarity as the portion, wherein the actual motion vector value as the opposite field polarity as the portion, and wherein the scaling is adapted to scale from the opposite polarity to the same polarity.
 34. The method of claim 27 wherein the scaling is based at least in part on a reference frame distance.
 35. A method of processing an interlaced predicted video frame, the method comprising: determining a first motion vector predictor candidate for a macroblock in a current field in the video frame, the first motion vector predictor candidate having a first polarity; determining a second motion vector predictor candidate for the macroblock, wherein the second motion vector predictor candidate is derived from the first motion vector predictor candidate using a scaling operation; and wherein the second motion vector predictor candidate has a polarity different than the first polarity.
 36. A computer-readable medium having stored thereon computer-executable instructions for performing the method of claim 35 in a video encoder.
 37. A computer-readable medium having stored thereon computer-executable instructions for performing the method of claim 35 in a video decoder.
 38. A method of processing an interlaced predicted video frame, the method comprising: determining a first motion vector predictor candidate for a macroblock in a current field in the video frame, the first motion vector predictor candidate referencing a field having a first polarity and a reference distance; and determining a second motion vector predictor candidate for the macroblock, wherein the second motion vector predictor candidate is derived from the first motion vector predictor candidate using a scaling operation that varies based at least in part on the reference distance.
 39. The method of claim 38 wherein the second motion vector predictor candidate has a polarity different than the first polarity.
 40. A computer-readable medium having stored thereon computer-executable instructions for performing the method of claim 38 in a video encoder.
 41. A computer-readable medium having stored thereon computer-executable instructions for performing the method of claim 38 in a video decoder.
 42. A method of decoding data for a current frame in an encoded video data bitstream, the method comprising: decoding a first element at a field level in the bitstream, the first element comprising number-of-reference-field information for a current field in the video frame, the number-of-references information indicating two reference fields for the current field; decoding a second element at a macroblock level in the bitstream, the second element comprising macroblock mode information for a current macroblock in the current field; and decoding a third element at the macroblock level, the third element comprising motion vector data for the current macroblock, wherein the motion vector data includes differential motion vector data; and processing the motion vector data for the macroblock, the processing comprising: determining first and second motion vector predictors for the current macroblock, wherein the first motion vector predictor is an odd field predictor and the second motion vector predictor is an even field predictor; and reconstructing a motion vector for the current macroblock based at least in part on the first and second motion vector predictors and based at least in part on the differential motion vector data.
 43. A method of decoding a current macroblock of an interlaced P-field, the method comprising: decoding motion vector data that collectively signal a horizontal differential motion vector component, a vertical differential motion vector component, and flag indicating whether to use a dominant or non-dominant motion vector predictor; and reconstructing a motion vector based at least in part on the decoded motion vector data.
 44. The method of claim 43 wherein motion vector is for the current macroblock.
 45. The method of claim 43 wherein motion vector is for one block of the current macroblock.
 46. The method of claim 43 wherein the reconstructing comprises: selecting between using the dominant motion vector predictor or the non-dominant motion vector predictor based on the flag; combining the horizontal differential motion vector component with a horizontal component of the selected predictor; and combining the vertical differential motion vector component with a horizontal component of the selected predictor. 